structure MipsFrame : FRAME =
struct
    structure E = ErrorMsg
    structure M = Temp
    structure R = Tree

    type register = string

    datatype access = InFrame of int
		    | InReg of M.temp

    (*
     * The first 4 parameters are passed in registers, with remaining ones passed on the stack
     *
     * The stack layout is
     *
     *  outgoing args                                 incoming args    older frames ...
     *                 temps | ret | locals | static parm ... parm | ...
     *               ^                      ^ 
     *              SP                     FP
     *  ... lower addresses ...................................... higher addresses ...
     *)

    type frame = ...

    val wordSize = 4
		   
    val RV = Temp.newtemp ()
    val FP = Temp.newtemp ()

    fun newFrame {name, formals} = ...

    fun formals {name, formals=formals, sp} = ...

    fun name {name=name, formals, sp} = ...
			
    fun allocLocal {name, formals, sp=sp} true  = ...
      | allocLocal _                      false = ..

    fun externalCall (s, args) = ...

(*
    val registers : register list
    val tempMap : register Temp.Table.table
    val string : M.label * string -> string
*)

    fun procEntryExit1 (frame, body) = body

(*
    val procEntryExit2 : frame * Assem.instr list -> Assem.instr list
    val procEntryExit3 : frame * Assem.instr list -> {prolog : string, body : Assem.instr list, epilog : string}
*)
    datatype frag = PROC of {body : R.stm, frame : frame}
		  | STRING of M.level * string
end
